<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<%@include file="../../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath}/public.css"/>
	<script type="text/javascript" src="${jspath }/jquery-1.4.4.js"></script>
	<script src="${jspath}/jquery/tree/jquery.jstree.js" type="text/javascript"></script>
	<script src="${jspath}/jquery/tree/dmsTree.js" type="text/javascript"></script>
	<script src="${jspath}/jquery/tree/menuSetTree.js" type="text/javascript"></script>
    <script type="text/javascript" src="${jspath}/jquery/jquery.ellipsis.js"></script>
	<script type="text/javascript"
	src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript"
	src="${jspath}/jquery/jquery.alerts.js"></script>
<link rel="stylesheet" type="text/css"
	href="${csspath}/jquery.alerts.css" />
	<script type="text/javascript">
		var checkedMenus = ${shortMenu};
		$(function() {
			
			//alert(checkedMenus);
			//buildTree();
			defaultShortcutMenuChecked(eval(checkedMenus));
			//alert(window.opener.document.getElementById("shortMenu").innerHTML);
			//alert("${userMenu}");
			$(window.parent.document).find("#shortMenu").html("${userMenu}");
			//$(window.parent.document).find(".longtext").wordLimit(3);
			window.parent.registerShortcutEvent();
			//$(window.parent.document).find(".shortcut").trigger("click");
			
			
			//alert($(window.parent.document).find("#shortMenu").html());
			/*$.ajax({
					type:'GET',
					url: '${webcontext}/ge/shortcutmenu/loadUserShortcutMenus',
					async: true,
					dataType : 'json',
					success : function(data) {
						var shortMenu="";
						for(i=0;i<data.length;i++){
							shortMenu+="<a href="+data[i].url+"><img src='${imagepath}/"+data[i].phoneUrl+"'/><span>"+data[i].menuName+"</span></a>";
						}
						$(window.parent.document).find("#shortMenu").html(shortMenu);
				    }
				});*/
			//alert();
			$("#ok").click(function(){
				selectIds = getCheckedValue();
				//alert(selectIds.length);
				if(selectIds.length==0){
					//jAlert("请至少选择一个快捷菜单！","提示信息");
					//return;
					selectIds=-1;
				}
				if(selectIds.length>6){
					jAlert("快捷菜单设置不能大于六个！","提示信息");
				}else{
					$("#login_form").attr("action","${webcontext}/ge/shortcutmenu/updateUserMenu/"+selectIds);
					$("#login_form").submit();
					/*$.ajax(function(){
						type: 'get',
						url : '${webcontext}/ge/shortcutmenu/updateUserMenu/'+selectIds,
						async : false,
						dataType : 'json',
						succes : function(data){
							jAlert("快捷菜单设置成功","提示信息");
						}
					});*/
				}
					
			});
		});
		
		
		function cancelBack(){
			parent.hideBoder();
			location.href="${webcontext}/mainpage/loginData";
		}
	</script>
</head>
<body>

<form:form id="login_form" name ="login_form" method="get">
<!-- content -->
	<div id="content">
		<!-- wrap -->
		<div id="wrap">

			<!-- breadcrumb -->
			<div id="breadcrumba" style="color: #025D7B; height: 26px; line-height: 26px;">
				<span>信息维护</span>
				<span>&gt;</span>
				<span>快捷菜单设置</span>
			</div>
			<!-- /breadcrumb -->

			<!-- input_div -->
			<div class="input_div">
				<div class="title">
					<span>快捷菜单设置</span>
				</div>
				<div id="menuSetTree" class="tree_div" class="demo"></div>
				<div class="spliter h_5"></div>
				<!-- btn_div -->
				<div class="btn_div">
					<input type="button" class="btn" value="确认" id="ok"/>
					<input type="button" class="btn" value="取消"
						onclick="cancelBack();"/>
				</div>
				<!-- /btn_div -->
				<div class="spliter h_5"></div>
			</div>
			<!-- /input_div -->

		</div>
		<!-- /wrap -->
	</div>
	<!-- /content -->
	</form:form>
</body>
</html>